<?
	$db = GetDefaultConnection();

	$queryarry = array(
		'a.T_PRODUCT_SEQ' => $seq,
	);

	$query=makeWhereQry($queryarry);

	if ($query != "")
		$where .= " and ". $query;

	$sql = sprintf("SELECT b.R_PRODUCT_SEQ, b.R_PRODUCT_DATE, b.R_PRODUCT_COUNTRY, b.R_PRODUCT_WEIGHT2, b.R_PRODUCT_LOSS, b.R_PRODUCT_NUMBER, b.R_PRODUCT_TOTAL "
					.", (select JBNH_NAME FROM TB_JBNH WHERE JBNH_SEQ=a.JBNH_SEQ) as JBNH_NAME "
					.", (select FARM_NAME FROM TB_FARM WHERE FARM_SEQ=a.FARM_SEQ) as FARM_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='A' AND CODE_CODE1=a.T_PRODUCT_ITEM1 AND CODE_CODE2=0) as ITEM1_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='A' AND CODE_CODE1=a.T_PRODUCT_ITEM1 AND CODE_CODE2=a.T_PRODUCT_ITEM2) as ITEM2_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='B' AND CODE_CODE1=b.R_PRODUCT_GRADE1 AND CODE_CODE2=b.R_PRODUCT_GRADE2) as GRADE2_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='B' AND CODE_CODE1=b.R_PRODUCT_STANDARD2 AND CODE_CODE2=b.R_PRODUCT_STANDARD2) as STANDARD2_NAME "
					." FROM TB_PRODUCT_TEMP a inner join TB_PRODUCT_RESULT b on a.T_PRODUCT_SEQ=b.T_PRODUCT_SEQ where 1=1 %s order by b.R_PRODUCT_SEQ desc "
					, $where);
	$list = $db->queryList($sql)
?>
<?
	if ($list->getLength() == 0)
	{
?>
                <tr>
                	<td colspan=14>등록된 목록이 없습니다.</td>
                </tr>
<?
	}
	else
	{
		$rtotal=0;
		while ($list->hasNext())
		{
			$row = & $list->next();
			$r_product_seq = $row->getNumber('R_PRODUCT_SEQ');
			$jbnh_name = $row->getString('JBNH_NAME');
			$farm_name = $row->getString('FARM_NAME');
			$r_product_country = $row->getString('R_PRODUCT_COUNTRY');
			$item1_name = $row->getString('ITEM1_NAME');
			$item2_name = $row->getString('ITEM2_NAME');
			$grade2_name = $row->getString('GRADE2_NAME');
			$standard2_name = $row->getString('STANDARD2_NAME');
			$r_product_loss = $row->getNumber('R_PRODUCT_LOSS');
			$r_product_weight2 = $row->getNumber('R_PRODUCT_WEIGHT2');
			$t_product_number = $row->getNumber('R_PRODUCT_NUMBER');
			$r_product_total = $row->getNumber('R_PRODUCT_TOTAL');
			$r_product_date = $row->getString('R_PRODUCT_DATE');
			$rtotal = $rtotal+$r_product_total;
?>
                <tr>
					<td><input type="checkbox" id="seq2" name="seq2" value="<?=$r_product_seq?>" title="수정/삭제시 체크" onclick="fnview(this.value);" /></td>
					<td><?=$r_product_date?></td>
					<td><?=$jbnh_name?></td>
					<td><?=$farm_name?></td>
					<td><?=$r_product_country?></td>
					<td><?=$item1_name?></td>
					<td><?=$item2_name?></td>
					<td><?=$grade2_name?></td>
					<td><?=$standard2_name?></td>
					<td><?=$r_product_weight2?>kg</td>
					<td><?=$r_product_loss?>kg</td>
					<td><?=$t_product_number?>개</td>
					<td><?=$r_product_total?>kg</td>
					<td class="start"><a href="#" onClick="doPrint('print_sunbyul.html?seq=<?=$r_product_seq?>', 1000, 600);"><p class="sort_print"><span>선별확인증 인쇄</span></p></a></td>
                </tr>
<?
		}
	}
?>
